def fib(n):
    a, b = 0, 1
    while a < n:
        print(a , end=' ')
        a,b = b, a+b
    print()

fib(2000)

f=fib
f(1000)
def fib2(n):
    result=[]
    a,b=0,1
    while a < n:
        result.append(a)
        a,b = b,a+b
    return result

print(fib2(200))

def ask_ok(prompt,retries=4,reminder='Please try again!'):
    while True:
        reply = input(prompt)
        if reply in {'y','ye','yes'}:
            return True
        if reply in {'n','no'}:
            return False
        retries = retries-1
        if retries<0:
            raise ValueError("invalid user response")
        print(reminder)

i =5
def f(arg=i):
    print(arg)
i=6
f()
def f(a,L=[]):
    L.append(a)
    return L
print(f(1))
print(f(2))
print(f(3))

def f(a,L=None):
    if L is None:
        L=[]
    L.append(a)
    return L
def parrot(voltage,state='a stiff' , action='voom' , type='Norwegian Blue'):
    print("--this parrot wouldn't" , action , end=' ')
    print("if you put" , voltage, "volts through it . ")
    print("-- Lovely plumage , the " , type)
    print("--it's " , state , "!")

# parrot(1000)
# parrot(voltage=2000)
# parrot(voltage=10000,action='VOOOOM')
# parrot(action='VOOOOSS' , voltage=2222)
# parrot('a millone' , 'bereft of life' , 'jump')
# parrot('a thousand' , state='pushing up the daisies')

def function(a):
    pass
function(0)

def cheeseshop(kind , *args,**keywords):
    print("--do you have any " , kind , "?")
    print("i'm sorry , we're all out of " , kind)

    for arg in args:
        print(arg)
    print("-" * 40 )
    for key in keywords:
        print(key , ":" , keywords[key])

cheeseshop("Limburger", "It's very runny, sir.",
           "It's really very, VERY runny, sir.",
           shopkeeper="Michael Palin",
           client="John Cleese",
           sketch="Cheese Shop Sketch")

def write_multiple_items(file, separator , *args):
    print(separator.join(args))
write_multiple_items('a' , '/' , "a" , "b","c","d")
def make_incrementor(n):
    return lambda x: x+n
f = make_incrementor(0)
print(f(1))
print(f(2))